import HomeService from '../services/home'
import { createAction, NavigationActions, Storage } from '../utils'
import { Toast } from 'antd-mobile';

export default {
    namespace: 'home',
    state: {
        indexInfo: {
            list: []
        },
        ref: true
    },
    subscriptions: {

    },
    effects: {
        *getindex({ payload }, { call, put }) {
            yield put({ type: 'setref', payload: true });
            const result = yield call(HomeService.Create, payload);
            yield put({ type: 'setref', payload: false });
            const { data } = result;
            if (data.rel) {
                //Toast.info(data.msg, 1);
                yield put({ type: 'setindex', payload: data });
            }
            else {
                //看data.msg
            }

        },
    },
    reducers: {
        setindex(state, { payload }) {
            return { ...state, indexInfo: payload }
        },
        setref(state, { payload }) {
            return { ...state, ref: payload }
        },
    },
}